package com.lntea.mybatisDemo.test;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Before;
import org.junit.Test;

import com.lntea.mybatisDemo.domain.CmCorporation;
import com.lntea.mybatisDemo.domain.TransRiskFlowInfo;
import com.lntea.mybatisDemo.mapper.CmCorporationMapper;
import com.lntea.mybatisDemo.mapper.TransRiskFlowInfoMapper;

public class TransRiskFlowInfoService {
	private SqlSessionFactory sqlSessionFactory;

	@Before
	public void beforeQuery() {
		String resource = "mybatis-config.xml";
		try {
			InputStream is = Resources.getResourceAsStream(resource);
			sqlSessionFactory = new SqlSessionFactoryBuilder().build(is);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	@Test
	// 查询风险交易签账单和台账
	public void queryRiskFlowList() {
		SqlSession session = sqlSessionFactory.openSession();
		try {
			TransRiskFlowInfoMapper mapper = session.getMapper(TransRiskFlowInfoMapper.class);
			List<TransRiskFlowInfo> list = mapper.queryRiskFlowList(168784);
			for(TransRiskFlowInfo temp : list){
				System.out.println(temp.getFilePath());
			}
		} finally {
			session.close();
		}
	}
	
	@Test
	//查询争执交易签账单和台账
	public void queryDiffFlowList(){
		SqlSession session = sqlSessionFactory.openSession();
		try {
			TransRiskFlowInfoMapper mapper = session.getMapper(TransRiskFlowInfoMapper.class);
			List<TransRiskFlowInfo> list = mapper.queryDiffFlowList(154563);
			for(TransRiskFlowInfo temp : list){
				System.out.println(temp.getFilePath());
			}
		} finally {
			session.close();
		}
	}
}
